using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>
    public class TVC_MVPDETControl
    {
        #region Local Variable
        private TVC_MVPDETDataAccess _objDAO;
        #endregion Local Variable

        #region Method

        public TVC_MVPDETControl(String bus)
        {
            business = bus;
            _objDAO = new TVC_MVPDETDataAccess();
        }
        public TVC_MVPDETInfo Get(string db, Int32 AUTO_ID, ref string sErr)
        {
            return _objDAO.Get(db, AUTO_ID, ref sErr);
        }
        /// <summary>
        /// Get by Code
        /// </summary>
        /// <param name="Code"></param>
        /// <param name="sErr"></param>
        /// <returns></returns>
        public DataTable Get(string db, string Code, ref string sErr)
        {
            return _objDAO.Get(db, Code, ref sErr);
        }
        public DataTable GetAll(string db, ref string sErr)
        {
            return _objDAO.GetAll(db, ref sErr);
        }

        public Int32 Add(string db, TVC_MVPDETInfo obj, ref string sErr)
        {
            return _objDAO.Add(db, obj, ref sErr);
        }

        public string Update(string db, TVC_MVPDETInfo obj)
        {
            return _objDAO.Update(db, obj);
        }

        public string Delete(string db, Int32 AUTO_ID)
        {
            return _objDAO.Delete(db, AUTO_ID);
        }
        public Boolean IsExist(string db, Int32 AUTO_ID)
        {
            return _objDAO.IsExist(db, AUTO_ID);

        }


        public string InsertUpdate(string db, TVC_MVPDETInfo obj)
        {
            string sErr = "";
            if (IsExist(db, obj.AUTO_ID))
                sErr = _objDAO.Update(db, obj);
            else _objDAO.Add(db, obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            TVC_MVPDETInfo inf = new TVC_MVPDETInfo();
            return inf.ToDataTable();
        }

        public string TransferIn(string db, DataRow row)
        {
            TVC_MVPDETInfo inf = new TVC_MVPDETInfo(row);
            return InsertUpdate(db, inf);
        }
        #endregion Method


        public string business { get; set; }


        public void DeletebyCode(string db, string Code, ref string sErr)
        {
            _objDAO.DeletebyCode(db, Code, ref sErr);

        }
    }
}
